
//=============================================================================
// Scene_Base
//=============================================================================

Scene_Base.prototype.clearChildren = function() {
    while (this.children.length > 0) {
      this.removeChild(this.children[0]);
    }
  };
  
  if (Yanfly.Param.CollectionClear) {
  
  Yanfly.Core.Scene_Base_terminate = Scene_Base.prototype.terminate;
  Scene_Base.prototype.terminate = function() {
    Yanfly.Core.Scene_Base_terminate.call(this);
    if (this._bypassFirstClear) return;
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Title_terminate = Scene_Title.prototype.terminate;
  Scene_Title.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Title_terminate.call(this);
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Map_terminate = Scene_Map.prototype.terminate;
  Scene_Map.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Map_terminate.call(this);
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Battle_terminate = Scene_Battle.prototype.terminate;
  Scene_Battle.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Battle_terminate.call(this);
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Options_terminate = Scene_Options.prototype.terminate;
  Scene_Options.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Options_terminate.call(this);
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Load_terminate = Scene_Load.prototype.terminate;
  Scene_Load.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Load_terminate.call(this);
    this.clearChildren();
  };
  
  Yanfly.Core.Scene_Gameover_terminate = Scene_Gameover.prototype.terminate;
  Scene_Gameover.prototype.terminate = function() {
    this._bypassFirstClear = true;
    Yanfly.Core.Scene_Gameover_terminate.call(this);
    this.clearChildren();
  };
  
  }; // Yanfly.Param.CollectionClear